<template>
    <el-menu
            :default-active="activeIndex"
            unique-opened
            background-color="#324157"
            text-color="#fff"
            active-text-color="#20a0ff"
            class="el-menu-vertical-demo" @select = "handleSelect">
        <el-submenu index="1" v-show='type==1'>
            <template slot="title">客户管理</template>
            <nuxt-link to="/customer">
                <el-menu-item index="1-1">我的客户</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/customer/add">
                <el-menu-item index="1-2">添加客户</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/customer/seas">
                <el-menu-item index="1-3">公海客户</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/customer/new-record">
                <el-menu-item index="1-4">新录资源</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/customer/missed-call">
                <el-menu-item index="1-5">未接电话管理</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/customer/brandlist">
                <el-menu-item index="1-6">品牌列表</el-menu-item>
            </nuxt-link>
        </el-submenu>

        <el-submenu index="2" v-show='type==1'>
            <template slot="title">客户报表</template>
            <nuxt-link to="/report">
                <el-menu-item index="2-1">新增客户统计</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/report/owner">
                <el-menu-item index="2-2">客户所有者统计</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/report/follow">
                <el-menu-item index="2-3">跟进量统计</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/report/destination">
                <el-menu-item index="2-4">客户去向统计</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/report/online">
                <el-menu-item index="2-5">在线统计</el-menu-item>
            </nuxt-link>
        </el-submenu>

        <el-submenu index="5" v-show='type==3'>
            <template slot="title">组织架构管理</template>
            <nuxt-link to="/power">
                <el-menu-item index="5-1">部门管理</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/power/post-manage">
                <el-menu-item index="5-2">岗位管理</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/power/user-control">
                <el-menu-item index="5-3">用户管理</el-menu-item>
            </nuxt-link>
        </el-submenu>

        <el-submenu index="4" v-show='type==3'>
            <template slot="title">权限管理</template>
            <nuxt-link to="/power/setting">
                <el-menu-item index="4-1">部门权限分配</el-menu-item>
            </nuxt-link>
            <<nuxt-link to="/power/setting-module">
                <el-menu-item index="4-2">权限模块管理</el-menu-item>
            </nuxt-link>
        </el-submenu>

        <el-submenu index="10" v-show='type==2'>
            <template slot="title">品牌管理</template>
            <nuxt-link to="/brandadmin">
                <el-menu-item index="10-1">品牌列表</el-menu-item>
            </nuxt-link>
        </el-submenu>

        <el-submenu index="11" v-show='type==2'>
            <template slot="title">sku管理</template>
            <nuxt-link to="/keyWord">
                <el-menu-item index="11-1">关键词列表</el-menu-item>
            </nuxt-link>
            <!--<nuxt-link to="/keyWord/indexUrl">
                <el-menu-item index="11-2">监控网址列表</el-menu-item>
            </nuxt-link>-->
        </el-submenu>

        <el-submenu index="12" v-show='type==2'>
            <template slot="title">授权商家管理</template>
            <nuxt-link to="/seller">
                <el-menu-item index="12-1">授权商家列表</el-menu-item>
            </nuxt-link>
        </el-submenu>
        
        <!-- <el-submenu index="22" v-show='type==2'>
            <template slot="title">监控计划</template>
            <nuxt-link to="/MonitorPlan">
                <el-menu-item index="22-1">监控计划列表</el-menu-item>
            </nuxt-link>
        </el-submenu> -->

        <el-submenu index="7" v-show='type==2'>
            <template slot="title">预警管理</template>
            <nuxt-link to="/warning/warnDesk">
                <el-menu-item index="7-1">预警工作台</el-menu-item>
            </nuxt-link>
            <!--<nuxt-link to="/warning/collectList">
                <el-menu-item index="7-2">预警汇总列表</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/warning/detailList">
                <el-menu-item index="7-3">预警明细列表</el-menu-item>
            </nuxt-link>-->
        </el-submenu>

        <el-submenu index="9" v-show='type==2'>
            <template slot="title">知识产权投诉管理</template>
            <nuxt-link to="/complaintlist">
                <el-menu-item index="9-1">产权投诉进度列表</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/complaintlist/auditfail">
                <el-menu-item index="9-2">投诉详情列表</el-menu-item>
            </nuxt-link>
        </el-submenu>


        <el-submenu index="21" v-show='type==2'>
            <template slot="title">推广管理</template>
            <nuxt-link to="/promotionalLog">
                <el-menu-item index="21-1">推广日志</el-menu-item>
            </nuxt-link>
        </el-submenu>

        <!--B2C运营-->
        <el-submenu index="13" v-show='type==4'>
            <template slot="title">店铺管理</template>
            <nuxt-link to="/b2cAdmin">
                <el-menu-item index="13-1">店铺明细</el-menu-item>
            </nuxt-link>
            <!--<nuxt-link to="/b2cAdmin/shopManage"> -->
            <!--<el-menu-item index="13-2">店铺认证</el-menu-item>-->
            <!--</nuxt-link>-->
        </el-submenu>
        <el-submenu index="14" v-show='type==4'>
            <template slot="title">短信记录</template>
            <nuxt-link to="/b2cAdmin/messageLog">
                <el-menu-item index="14-1">单表查询</el-menu-item>
            </nuxt-link>
        </el-submenu>
        <el-submenu index="15" v-show='type==4'>
            <template slot="title">推广连接</template>
            <!--<nuxt-link to="/b2cAdmin/trend">
                <el-menu-item index="15-1">趋势</el-menu-item>
            </nuxt-link>-->
            <nuxt-link to="/b2cAdmin/promotionLink">
                <el-menu-item index="15-1">推广日志</el-menu-item>
            </nuxt-link>
        </el-submenu>
        <el-submenu index="16" v-show='type==4'>
            <template slot="title">资讯管理</template>
            <nuxt-link to="/b2cAdmin/formMan">
                <el-menu-item index="16-1">资讯列表</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/b2cAdmin/helpList">
                <el-menu-item index="16-2">帮助中心</el-menu-item>
            </nuxt-link>
        </el-submenu>


        <el-submenu index="17" v-show='type==4'>
           <template slot="title">营销管理</template>
           <nuxt-link to="/b2cAdmin/marketList">
               <el-menu-item index="17-1">分销裂变</el-menu-item>
           </nuxt-link>
           <nuxt-link to="/b2cAdmin/marketList/discountlist">
               <el-menu-item index="17-2">限时折扣</el-menu-item>
           </nuxt-link>
           <nuxt-link to="/b2cAdmin/marketList/couponlist">
               <el-menu-item index="17-3">满减送</el-menu-item>
           </nuxt-link>
           <nuxt-link to="/b2cAdmin/marketList/entryGift">
               <el-menu-item index="17-4">优惠宝</el-menu-item>
           </nuxt-link>
       </el-submenu>
        <el-submenu index="18" v-show='type==4'>
            <template slot="title">用户统计</template>
            <nuxt-link to="/userStatistics/userProfile">
                <el-menu-item index="18-1">用户概况</el-menu-item>
            </nuxt-link>
        </el-submenu>
        <el-submenu index="19" v-show='type==4'>
            <template slot="title">信息通知</template>
            <nuxt-link to="/inform">
                <el-menu-item index="19-1">更新通知</el-menu-item>
            </nuxt-link>
        </el-submenu>


        <el-submenu index="101" v-show='type==4'>
             <template slot="title">商品管理</template>
             <nuxt-link to="/product">
                 <el-menu-item index="101-1">商品列表</el-menu-item>
             </nuxt-link>
             <nuxt-link to="/product/category">
                 <el-menu-item index="101-2">商品类目</el-menu-item>
             </nuxt-link>
         </el-submenu>

         <el-submenu index="102" v-show='type==4'>
             <template slot="title">订单管理</template>
             <nuxt-link to="/orders">
                 <el-menu-item index="102-1">订单列表</el-menu-item>
             </nuxt-link>
         </el-submenu>

         <!--<el-submenu index="103" v-show='type==4'>
             <template slot="title">数据报表</template>
             <nuxt-link to="/dataReport">
                 <el-menu-item index="103-1">推广分配统计</el-menu-item>
             </nuxt-link>
             <nuxt-link to="/dataReport/conversion-rate">
                 <el-menu-item index="103-2">转化率统计</el-menu-item>
             </nuxt-link>
         </el-submenu>-->

        <el-submenu index="3" v-show='type!=3 && type!=4'>
            <template slot="title">日历管理</template>
            <nuxt-link to="/calender" v-show='type==1'>
                <el-menu-item index="3-1">我的日历</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/calender/index_calender" v-show='type==2'>
                <el-menu-item index="3-1">我的日历</el-menu-item>
            </nuxt-link>
        </el-submenu>

        <el-submenu index="6" v-show='type!=3 && type!=4'>
            <template slot="title">配置管理</template>
            <nuxt-link to="/setting"  v-show='type==1'>
                <el-menu-item index="6-1">小计模板管理</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/setting/message"  v-show='type==1'>
                <el-menu-item index="6-2">短信模板管理</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/power/tel-management"  v-show='type==1'>
                <el-menu-item index="6-3">呼叫系统管理</el-menu-item>
            </nuxt-link>
            <nuxt-link to="/setting/Rights" v-show='type==2'>
                <el-menu-item index="6-4">维权抓取设置</el-menu-item>
            </nuxt-link>
        </el-submenu>

    </el-menu>
</template>

<script>
    import Vue from 'vue'
    import { mapGetters} from 'vuex';
    import { Col ,Menu ,MenuItem,MenuItemGroup,Submenu} from 'element-ui'
    import { setToken } from '~/utils/auth'

    Vue.use(Col);
    Vue.use(Menu);
    Vue.use(MenuItem);
    Vue.use(MenuItemGroup);
    Vue.use(Submenu);

    export default{
        data(){
            return {
                type: 1,
            }
        },
        methods: {
            handleSelect(Index) {
                setToken('parentUrl','login');
            },
            getType() {
                if (!process.BROWSER_BUILD) {
                    return false;
                }
                if (sessionStorage.type) {
                    this.type = sessionStorage.type
                }else {
                    this.type = 1
                }
                if (this.type == 1) {//切换tab跳转网页
                    this.$router.push('/customer')
                }else if(this.type == 2) {
                    this.$router.push('/brandadmin')
                }else if(this.type == 3) {
                    this.$router.push('/power')
                }else if(this.type == 4){
                    this.$router.push('/b2cAdmin')
                }
            }
        },
        computed : {
            ...mapGetters({
                'activeIndex' : 'getActiveIndex'
            })
        },
        created() {
            if (!process.BROWSER_BUILD) {
                return false;
            }
            if (sessionStorage.type) {
                this.type = sessionStorage.type
            }else {
                this.type = 1
            }
        }
    }
</script>

<style scoped lang="scss">
    .el-menu {
        width:201px;
        min-height: 100%;
        height: 100%;
        box-sizing: border-box;
        border-radius: 0;
        position: fixed;
        left: 0;
        z-index: 150;
        padding-top: 90px;
        top:0;
        bottom:0;
        overflow-y:auto;
        overflow-x: hidden
    }

</style>